﻿Partial Public Class PeriodExplorer

    Public Overridable Sub InitNewLayoutRow(sender As Object, e As InitNewRowEventArgs)
        Dim LayoutView As LayoutView = CType(sender, LayoutView)
        Dim row As DataRow = LayoutView.GetFocusedDataRow()
        Using aPeriod As SystemBoxSDK.PL.ABCSDK.Periods_PL = New ABCSDK.Periods_PL
            aPeriod.NewRecord(row)
        End Using
        row("Inactive") = 0
    End Sub

    Public Overridable Sub InitNewMasterRow(sender As Object, e As InitNewRowEventArgs)
        Dim view As GridView = CType(sender, GridView)
        Dim row As DataRow = view.GetFocusedDataRow()
        Using aPeriod As SystemBoxSDK.PL.ABCSDK.Periods_PL = New ABCSDK.Periods_PL
            aPeriod.NewRecord(row)
        End Using
    End Sub



    Public Overridable Sub TreeActionOptionListLoad()

        Me.MetaControlTreeListActionOptionList.Add(New ActionOption("SpecRoot", "ACT_00xxx", "Grid Update", AddressOf Periods_GridUpdate, True, True, 0))
        Me.MetaControlTreeListActionOptionList.Add(New ActionOption("SpecRoot", "ACT_00xxx", "Card View", AddressOf Periods_LayoutUpdate, True, True, 0))

    End Sub



    Private Sub Periods_GridUpdate()
        Me.Cursor = Cursors.WaitCursor


        PL = PLBase.CreateInstanceOf(PLTypeOf.Periods_PL, "Periods")
        aGridControl = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = PL, .CtrlName = "FRM_00017"}
        AddHandler aGridControl.InitNewMasterRow, AddressOf InitNewMasterRow
        For Each aFrm As XtraForm In Me.ParentForm.MdiChildren
            If aFrm.Name = PanelName Then
                aFrm.Controls.Clear()
                aFrm.Controls.Add(aGridControl)
                aFrm.Text = aGridControl.Pl.QueryName
                aFrm.Show()
            End If
            aFrm.Refresh()
        Next

        Me.Cursor = Cursors.Default

    End Sub



    Private Sub Periods_LayoutUpdate()
        Try

            Me.Cursor = Cursors.WaitCursor

            PL = PLBase.CreateInstanceOf(PLTypeOf.Specification_PL, "Periods")
            aGridLayout = New GridLayoutPL() With {.Dock = DockStyle.Fill, .Pl = PL, .FormCtrlCD = Nothing}

            For Each aFrm As XtraForm In Me.ParentForm.MdiChildren
                If aFrm.Name = PanelName Then
                    aFrm.Controls.Clear()
                    aFrm.Controls.Add(aGridLayout)
                    aFrm.Text = aGridLayout.Pl.QueryName
                    aFrm.Show()
                End If
                aFrm.Refresh()
            Next

            AddHandler aGridLayout.InitNewMasterRow, AddressOf InitNewLayoutRow

            Me.Cursor = Cursors.Default
        Catch ex As Exception
            MessageWindow.ShowMessage(ex, MsgBoxStyle.Information)
        End Try
    End Sub




End Class
